﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using MakeIT.MiraPark.Negocios;
using MakeIT.MiraPark.Apresentacao.Estatisticas;
using MakeIT.MiraPark.Apresentacao.Estatisticas.EstatisticasTableAdapters;
using Microsoft.Reporting.WinForms;

namespace MiraPark
{
    public partial class FormReportEMensalAnalitico : Form
    {

        public FormReportEMensalAnalitico()
        {
            InitializeComponent();
        }
        private void FormReportEMensalAnalitico_Load(object sender, EventArgs e)
        {
        }

        private void buttonImprimir_Click(object sender, EventArgs e)
        {
            DateTime? dataIni = null;
            DateTime? dataFim = null;

            try { dataIni = DateTime.Parse(this.maskedTextBoxDataIniP.Text); }
            catch (Exception ex) { };
            try { dataFim = DateTime.Parse(this.maskedTextBoxDataFimP.Text); }
            catch (Exception ex) { };

            if (dataIni == null || dataFim == null)
            {
                MessageBox.Show("Informe o periodo", "Aviso");
                return;
            }
            if (dataIni.Value > dataFim.Value)
            {
                MessageBox.Show("Data inicial maior que final", "Aviso");
                return;
            }

            this.reportViewer1.LocalReport.DataSources.Clear();

            eMensalAnaliticoTableAdapter emata = new eMensalAnaliticoTableAdapter();
            MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.eMensalAnaliticoDataTable emadt = new MakeIT.MiraPark.Apresentacao.Estatisticas.Estatisticas.eMensalAnaliticoDataTable();
            emadt = emata.GetData(dataIni, dataFim);
            this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Estatisticas_eMensalAnalitico", (DataTable) emadt));

            this.reportViewer1.RefreshReport();
        }

    }
}
